#define SO_VENDOR_NINTENDO 0x0000 // Nintendo TCP/IP stack
#define SO_VERSION 0x0100 // Version 1.0
// Name for SOConfig.alloc() and SOConfig.free()
#define SO_MEM_TCP_INFO 0
#define SO_MEM_TCP_SENDBUF 1
#define SO_MEM_TCP_RECVBUF 2
#define SO_MEM_UDP_INFO 3
#define SO_MEM_UDP_RECVBUF 4
#define SO_MEM_TIMEWAITBUF 5
#define SO_MEM_REASSEMBLYBUF 6
// Flags for SOConfig{}.flag
#define SO_FLAG_DHCP 0x0001 // Use DHCP
#define SO_FLAG_PPPoE 0x0002 // Use PPPoE
typedef struct SOConfig
{
u16 vendor; // SO_VENDOR_NINTENDO
u16 version; // SO_VERSION
//
// vendor specific section
//
void* (* alloc )(u32 name, s32 size);
void (* free ) (u32 name, void* ptr, s32 size);
u32 flag; // ORed SO_FLAG_*
SOInAddr addr;
SOInAddr netmask;
SOInAddr router;
SOInAddr dns1;
SOInAddr dns2;
s32 timeWaitBuffer; // time wait buffer size
s32 reassemblyBuffer; // reassembly buffer size
s32 mtu; // maximum transmission unit size
// TCP
s32 rwin; // default TCP receive window size (default 2 x MSS)
OSTime r2; // default TCP total retransmit timeout value (default 100 sec)
// PPP
const char* peerid;
const char* passwd;
// PPPoE
const char* serviceName; // UTF-8 string
// DHCP
const char* hostName; // DHCP host name
s32 rdhcp; // TCP total retransmit times (default 4)
// UDP
s32 udpSendBuff; // default UDP send buffer size (default 1472)
s32 udpRecvBuff; // defualt UDP receive buffer size (default 4416)
} SOConfig;
SO_VENDOR_NINTENDO implementation:When the socket layer requires a new memory block, it calls the alloc
function. The name argument shall be one of SO_MEM_*
that indicates the type of memory block to be used. The alloc function must
allocate the size bytes of memory block and return the pointer to
the allocated memory block. When the stack layer can release an allocated memory
block, it calls free function. The free function must release the
memory block pointed by the ptr argument. The other name
and size arguments are same as in the alloc function.
Mutual exclusion among threads is required for the implementaion of
alloc and free functions.
The thread level synchronization primitives like
OSLockMutex
can be used as the alloc and free functions are not
directly called from the callback function.
If SO_FLAG_DHCP is set to SOConfig.flag member, the
host is configured using DHCP. If SO_FLAG_PPPoE is set to SOConfig.flag
member, the host is configured using PPPoE. If the PPP session requires PAP or
CHAP authentication, peerid and passwd members must
also be set appropriately. Otherwise, addr, netmask
and router members are used to setup the host.
Optional dns1 and dns2
members are used to specify
up to two DNS server addresses,
which are used by SOGetHostByAddr()
and SOGetHostByName() functions.
timeWaitBuffer specifies the time wait buffer size. If zero is
specified, no buffer is allocated at all. The time wait buffer is a run-time
buffer used for maintaining TCP connections in the TIME_WAIT state. To prevent delayed
packets from being accepted by a later connection reincarnation and to complete
the TCP's full-duplex closing of a connection, the socket library
keeps actively closed connection information in memory until 2 MSL
timeout (RFC recommended value is four minutes). The socket library separately maintains connections that move to the TIME_WAIT
state in the time-wait buffer, where each connection occupies 24 bytes. The size required
for the time-wait buffer depends on how frequently the application performs the TCP active connection close. For example, with 1024 byte time-wait
buffer, the mean active close rate should not be faster than about once per 5.6 second
[(2 * MSL) / (1024 / 24) = 5.6...]. Note that when a connection is actively closed and if there is no free space
in the time-wait buffer, the socket library discards the oldest entry in the
time-wait buffer. If it happened, the other-end of the connection might not be
able to complete the TCP's full-duplex closing of a connection, and delayed
packets could be accepted by a later connection reincarnation.
reassemblyBuffer specifies the reassembly buffer size. If zero
is specified, no buffer is allocated at all. The IP fragment packets are kept in
the reassembly buffer before they are reassembled.
mtu specifies the default interface maximum transmission unit (MTU)
size in bytes. If zero is specified, the interface
default MTU size will be used. If the host is configured via DHCP or PPPoE, the
host will negotiate with the DHCP server or a PPPoE access concentrator for the
MTU size, and a smaller MTU size might be used after the host configuration. The
actual MTU size can be get with IPGetMtu()
function.
rwin specifies the default TCP receive window size. If zero is specified, 2 x MSS (maximum segment size) will be used.
r2 specifies the default total retransmission timeout value for
TCP connections after they are established. If zero is
specified, the default 100 seconds (recommended by RFC) is used.
serviceName specifies the PPPoE service name to be used when
connecting via PPPoE.
hostNamespecifies the DHCP client host name to be used when
connecting via DHCP.
rdhcp specifies the maximum retry count of the DHCP request
packet transmission. If zero is specified, the default four will be set.
udpSendBuff specifies the default UDP send buffer size. If zero
is specified, 1472 bytes will be used. udpSendBuff plus 20 (the
minimum IP header size) also specifies the maximum IP datagram size that can be
reassembled from IP fragment packets, and thus reassemblyBuffer
must be larger enough than udpSendBuff.
udpRecvBuff the he default UDP receive buffer size. If zero is
specified, 4416 bytes will be used.